<%@page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<script type="text/javascript">
	var form_url = $tools.basePath+"/hrmgr/companyAction/add.do" ;
	var s1 ;
	$(function() {
		s1 = $("#select1").combotree({
			url : $tools.basePath+"/hrmgr/companyAction/treegrid.do",
			idFiled:'pid', textFiled:'name', editable: false,
			lines:true, autoShowPanel: true
	    });
		
		//编辑，加载表单数据
		if($('input[name=id]').val().length > 0) {
			form_url = $tools.basePath+"/hrmgr/companyAction/edit.do" ;
			$.post($tools.basePath+"/hrmgr/companyAction/get.do", {id:$('input[name=id]').val()}, function(result) {
				if (result.id != undefined) {
					$('form').form('load', {
						'id' : result.id,
						'name' : result.name,
						'tel' : result.tel,
						'fax' : result.fax,
						'pid' : result.pid
					});
				}
			}, 'json');
		}
		$("#form input:visible")[0].focus();
	});
	
	//提交表单数据
	var submitNow = function($d, $t) {
		$.post(form_url, $("#form").form("getData"), function(result) {
			if (result.status) {
				$t.tree('reload') ;
				alertify.success(result.msg);$.easyui.loaded(); $d.dialog("close") ;
			} else {
				$.easyui.loaded();alertify.error(result.msg);;
			}
		}, 'json');
	};
	
	//验证表单
	var submitForm = function($d, $t) {
		if($('#form').form('validate')) {
			$.easyui.loading({ msg: "数据提交中，请稍等..." });
			submitNow($d, $t) ;
		}
	};
	
	
</script>
<div class="dialog_centent">
	<form id="form" class="easyui-form">
		<input type="hidden" name="id" value="${id}" />
		<table class="grid">
			<tr>
				<td>名称：</td>
				<td><input name="name" class="easyui-validatebox" type="text" data-options="required: true,prompt: '单位名称'" /></td>
				<td>代码：</td>
				<td><input name="code" class="easyui-validatebox" type="text" data-options="prompt: '机构代码'" /></td>
			</tr>
			<tr>
				<td>电话：</td>
				<td><input name="tel" class="easyui-validatebox" type="text" data-options="" /></td>
				<td>传真：</td>
				<td><input name="fax" class="easyui-validatebox" type="text" data-options="" /></td>
			</tr>
			<tr>
				<td>邮政邮政：</td>
				<td><input name="post_code" class="easyui-validatebox" type="text" data-options="" /></td>
				<td>地址：</td>
				<td><input name="addr" class="easyui-validatebox" type="text" data-options="" /></td>
			</tr>
			<tr>
				<td>网址：</td>
				<td colspan="3"><input name="site" style="width:558px;" class="easyui-validatebox" type="text" data-options="" /></td>
			</tr>
			<tr>
				<td>上级：</td>
				<td colspan="3"><select id="select1" name="pid" style="width:218px;height:30px;"></select><a onClick="s1.combotree('setValue','');" class="easyui-linkbutton" data-options="plain: true, iconCls: 'ext_clear'"></a></td>
			</tr>
		</table>
	</form>
</div>